import 'package:cook_dinner/pages/search/search_view/search_list.dart';
import 'package:cook_dinner/pages/search/search_view/search_top.dart';
import 'package:cook_dinner/widgets/input.dart';
import 'package:flutter/material.dart';
import 'package:cook_dinner/config/include.dart';

class SearchPage extends StatefulWidget {
  const SearchPage({Key? key}) : super(key: key);

  @override
  State<SearchPage> createState() => _SearchPageState();
}

class _SearchPageState extends State<SearchPage> {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.translucent,
      onTap: () {
        FocusScope.of(context).unfocus();
      },
      child: Scaffold(
        resizeToAvoidBottomInset: true,
        appBar: PreferredSize(
          preferredSize: Size.fromHeight(108.rpx),
          child: Container(
            color: Colors.white,
            padding: EdgeInsets.only(left: 25.rpx, right: 25.rpx, top: 60.rpx),
            child: Row(
              children: [
                Expanded(
                  child: Container(
                    width: double.infinity,
                    height: 48.6.rpx,
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(15.rpx),
                      color: const Color(0xffD3D2D8).withOpacity(0.51),
                    ),
                    child: Row(
                      children: [
                        Padding(
                          padding:
                              EdgeInsets.only(left: 17.rpx, right: 13.8.rpx),
                          child: Image.asset(
                            'assets/images/search2.png',
                            width: 26.51.rpx,
                            height: 26.51.rpx,
                          ),
                        ),
                        Expanded(
                          child: textInput(
                            hintText: '搜索您想要的内容',
                            fontSize: 18.rpx,
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
                Padding(
                  padding: EdgeInsets.only(left: 22.rpx, right: 10.rpx),
                  child: InkWell(
                    onTap: () => Navigator.pop(context),
                    child: Text(
                      '取消',
                      style: TextStyle(
                        fontSize: 18.rpx,
                        color: const Color(0xffA6A7A2),
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
        body: const CustomScrollView(
          slivers: [
            SliverToBoxAdapter(
              child: SearchHistory(),
            ),
            SearchList(),
          ],
        ),
      ),
    );
  }
}
